package org.dev.vlp.controller;

import org.dev.vlp.bean.JsonResponse;
import org.dev.vlp.constants.Roles;
import org.dev.vlp.interceptor.RequiredPermission;
import org.dev.vlp.service.MomentService;
import org.dev.vlp.service.TopicService;
import org.dev.vlp.utils.PageResult;
import org.dev.vlp.vo.MomentVo;
import org.dev.vlp.vo.TopicVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * Description
 * Param
 * return
 * Author:86184
 * Date: 2023/1/11
 */
@RestController
@RequestMapping("/topic")
@RequiredPermission({Roles.ROLE_USER})
public class TopicController {

    @Autowired
    private TopicService topicService;

    @Autowired
    private MomentService momentService;

    @GetMapping
    public JsonResponse<List<TopicVo>> queryTopic() {
        return JsonResponse.success(topicService.queryTopic());
    }

    @GetMapping("/{topicId}")
    public JsonResponse<PageResult> queryTopicMoment(@PathVariable("topicId") int topicId,
                                                     @RequestParam int page,
                                                     @RequestParam int size) {
        PageResult momentVos = momentService.queryTopicMoment(topicId, size, page);
        return JsonResponse.success(momentVos);
    }
}
